function a(a) {
    for (var t = [], e = a.length + 1; e > 0; ) {
        e--;
        var n = Math.floor(Math.random() * a.length);
        if (t.includes(a[n])) {
            if (t.length == a.length) break;
            e++;
        } else t.push(a[n]);
    }
    return t;
}

for (var t = getApp(), e = require("../data.js").allData, n = require("../jin.js").jin.split(","), i = [], o = require("../../utils/util.js"), s = [ "晴", "雨", "多云", "雷雨", "阵雨", "小雨", "阴" ], r = 0; r < 81; r++) i.push(r);

Page({
    data: {
        value: "",
        datas: [],
        time: "",
        name: "设置昵称",
        avatar: "../../img/1.jpg",
        pickValue: 0,
        imgList: [ {
            id: "../../img/1.jpg",
            name: "熊猫-男"
        }, {
            id: "../../img/2.jpg",
            name: "熊猫-女"
        }, {
            id: "../../img/3.jpg",
            name: "卡通狗头"
        } ],
        openWrap: !1,
        openName: "modal",
        nicheng: "",
        jinci: ""
    },
    // GetApi: function() {
    //     var t = this;
    //     wx.request({
    //         url: "https://api.oddfar.com/yl/q.php?c=1006&encode=text",
    //         method: "get",
    //         success: function(e) {
    //             console.log(e)
    //             var n = e.data.replace(/<br>/g, "\n");
    //             console.log(n), t.setData({
    //                 content: n
    //             });
    //         }
    //     });
    // },
    onLoad: function() {
        var a = wx.getStorageSync("name"), t = wx.getStorageSync("avatar");
        a && t && this.setData({
            avatar: t,
            name: a
        }), this.randomNumber(), this.bindRandomText();
    },
    onReady: function() {},
    onShow: function() {},
    randomDateType: function() {
        var a = new Date(), t = "星期" + "天一二三四五六 ".charAt(a.getDay());
        return o.formatDate2(a) + " " + t + " ";
    },
    randomNumber: function() {
        var t = a(i), n = t.shift();
        this.setData({
            datas: t,
            value: e[n]
        });
    },
    randomText: function() {
        var a = o.randomNum(0, s.length - 1);
        return s[a];
    },
    bindRandomText: function(a) {
        this.setData({
            time: this.randomDateType()
        });
    },
    randeNext: function() {
        var t = this, n = this.data.datas;
        wx.showLoading({
            title: "正在生成中..."
        });
        var o = [];
        o = n.length ? n : a(i), setTimeout(function() {
            var a = o.shift();
            t.setData({
                datas: o,
                value: e[a]
            }, function() {
                return wx.hideLoading();
            });
        }, 400);
    },
    copy: function() {
        var a = this.data, t = a.value, e = a.time;
        wx.setClipboardData({
            data: e + " " + t,
            success: function(a) {
                wx.showToast({
                    title: "复制成功!"
                });
            }
        });
    },
    openAD: function() {
        if ("设置昵称" === this.data.name) return wx.showToast({
            title: "请设置昵称",
            icon: "none"
        });
        this.createCard();
    },
    createCard: function() {
        var a = this.data, e = a.value, i = a.name, o = a.avatar, s = a.time, r = !0;
        if ("设置昵称" === i) return wx.showToast({
            title: "请设置昵称",
            icon: "none"
        });
        wx.showLoading({
            title: "内容检测中..."
        });
        for (var u = 0; u < n.length; u++) if (e.includes(n[u])) {
            r = !1, console.log(n[u]), this.setData({
                jinci: n[u]
            });
            break;
        }
        r ? (t.globalData.result = {
            value: e,
            name: i,
            avatar: o,
            time: s
        }, wx.setStorageSync("avatar", o), this.setData({
            jinci: ""
        }, function() {
            wx.navigateTo({
                url: "../../pages/result/index"
            });
        })) : wx.showModal({
            title: "检测到有违禁词",
            content: "当前检测到违禁词 " + this.data.jinci + ",请更新后再提交"
        }), wx.hideLoading();
    },
    inputFn: function(a) {
        var t = a.detail.value;
        this.setData({
            value: t
        });
    },
    changeName: function() {
        this.setData({
            openWrap: !0,
            openName: "modal open"
        });
    },
    close: function() {
        this.setData({
            openName: "modal",
            openWrap: !1
        });
    },
    nichengInput: function(a) {
        var t = a.detail.value;
        this.setData({
            nicheng: t
        });
    },
    cName: function() {
        var a = this.data.nicheng, t = !0;
        if (!a.trim()) return wx.showToast({
            title: "昵称不能为空!",
            icon: "none"
        });
        wx.showLoading({
            title: "昵称检测中..."
        });
        for (var e = 0; e < n.length; e++) if (a.includes(n[e])) {
            t = !1, console.log(n[e]), this.setData({
                jinci: n[e]
            });
            break;
        }
        t ? (wx.showToast({
            title: "设置成功!"
        }), this.setData({
            jinci: "",
            openName: "modal",
            openWrap: !1,
            name: a
        }), wx.setStorageSync("name", a)) : wx.showModal({
            title: "检测到有违禁词",
            content: "当前检测到违禁词 " + this.data.jinci + ",请更新后再提交"
        }), wx.hideLoading();
    },
    bindPickerChange: function(a) {
        var t = a.detail.value, e = this.data.imgList;
        this.setData({
            pickValue: t,
            avatar: e[t].id
        }), wx.setStorageSync("avatar", e[t].id);
    },
    onShareAppMessage: function(a) {
        return {
            title: "做舔狗呢，最重要的是开心",
            path: "pages/tiangou/pages/index/index",
            imageUrl: "../../img/1.jpg"
        };
    }
});